# ***meta charset="UTF-8"***
# @Time: 2021/2/2 16:16
# @Author: 邢光强
# @Email： 1062584918@qq.com
# @File： email_invitation_case.py
# @Project: crm_project

from pages.login_page import LoginPage
from time import sleep
from pages.home_page import HomePage
from pages.organization_page import OrganizationPage
from pages.add_user_page import AddUserPage
from cases.base_case import BaseCase

class EmailInvitationTestCase(BaseCase):
    def test_email_invitation_case(self):
        lp = LoginPage(self.driver)
        lp.open()  # 打开登录页面
        lp.input_username("龙龙")  # 输入用户名
        lp.input_password("123456")  # 输入密码
        lp.submit()  # 点击确定
        sleep(2)
        hp = HomePage(self.driver)
        actual = hp.get_current_url()
        self.assertAlmostEqual(hp.url, actual)
        # 进入主页,点击右上角头像
        hp.click_touxiang()
        sleep(2)
        # 点击组织架构
        hp.click_zzgj()
        sleep(2)
        # 组织架构页面，点击添加用户
        op = OrganizationPage(self.driver)
        op.add_user()
        sleep(1)

        adp = AddUserPage(self.driver)
        # 点击邮箱邀请
        adp.click_yxyq()
        sleep(1)
        #输入用户名
        adp.input_yx_username("猪猪猪猪")
        sleep(1)
        #输入邮箱
        adp.input_email("abcde@12345678.com")
        sleep(1)
        #选择用户类别
        adp.yx_category_select().select_by_visible_text("员工")
        #选择部门
        adp.yx_department_select().select_by_visible_text("销售部")
        sleep(1)
        #选择岗位
        adp.yx_role_select().select_by_visible_text("销售代表")
        #点击添加
        adp.yx_submit()
        sleep(2)
        #断言
        actual = op.tip()
        expect = "添加成功，等待被邀请用户激活!"
        self.assertIn(expect,actual)

